#!/bin/bash


# 获取当前脚本目录位置
cd `dirname $0`
dir=`pwd`
echo ${dir}

originFolderPath=${dir}/;
targetFolderPath=$HOME/.pip;
# 判断是文件夹/文件夹软链接是否已经存在
if [[ "$(readlink ${targetFolderPath})" = "${originFolderPath}" ]]; then
   #echo "[INFO]: 文件夹软链接已经存在 ";
   echo "${targetFolderPath} ==>${originFolderPath} 文件夹软链接已经存在"
else
    if [ -L "$targetFolderPath" ] || [ -d "$targetFolderPath" ] ; then
        echo "[INFO] 备份文件夹/文件夹软链接 ${targetFolderPath}";
        cmdStr="mv ${targetFolderPath} ${targetFolderPath}-`date +%y%m%d%H%M%S`";
        echo "执行命令: ${cmdStr}";
        ${cmdStr}
    fi
    echo "[INFO]: 创建文件夹软链接";
    cmdStr="ln -s  ${originFolderPath}  ${targetFolderPath}"
    echo "执行命令: ${cmdStr}";
    ${cmdStr}

    # 执行命令
    echo "执行命令: ${commandStr}";
    ${commandStr}
fi
